﻿using System;
using System.Collections.Generic;
using System.Text;
using NetworkLib.Utilities;

namespace PokemonBattle.BattleNetwork
{
    public enum TieMessage : int
    {
        TieRequest = -1115504277,
        AgreeTie = -803423805,
        RefuseTie = -1091278321,
        Fail = 1605126695,
        WrongInput = -1
    }

    public static class TieMessageHelper
    {
        public static TieMessage ReadFromByteArray(ByteArray byteArray)
        {
            int val = byteArray.ReadInt();
            return Parse(val);
        }

        public static TieMessage Parse(int val)
        {
            foreach (int value in Enum.GetValues(typeof(TieMessage)))
            {
                if (value == val) return (TieMessage)value;
            }
            return TieMessage.WrongInput;
        }

        public static void WriteToByteArray(ByteArray byteArray, TieMessage value)
        {
            byteArray.WriteInt((int)value);
        }
    }
}
